package com.base;

public class CompeareLength {
	public static void main(String[] args) {
		String a="asdfdsgfg";
		String b="sdfasdfw";
		System.out.println(compare(a, b));
	}
	public static String compare(String a,String b){
		String longer=a.length()>b.length()?a:b;
		String shorter=a.length()<=b.length()?a:b;
		for(int i=shorter.length();i>=1;i++){
			for(int j=0;j<a.length()-i-1;j++){
				String temp=shorter.substring(j, j+i);
				if(longer.contentEquals(temp)){
					return temp;
				}
			}
		}
		return null;
	}
}
